<?php
class MainController extends ControllerAbstract{
	public function checkUserPermision($userPermision){
		//przykład
		$page = $this->main->get->prepare('page');
		switch($page){
			case 'aboutUs':
				return $this->session->userLoggedIn();
				break;
			default:
				return true;
				break;
		}
	}
	public function init(){
		//Wybór odpowiedniego widoku
		$page = $this->get->get('page');
		switch($page){
			case 'aboutUs':
				$this->view = new AboutUsMainView();
				echo 'dejm';
				break;
			default:
				$this->view = new UserListMainView();
			break;
		}
		$this->view->loggedIn = $this->session->userLoggedIn();
	}
	public function begin(){
		
		switch($this->main->get->getAction()){
			case 'login':
				$this->main->session->logIn('1', 'perm');
				header("Location: index.php");
			break;
			case 'logout';
				$this->main->session->logOut();
				header("Location: index.php");
			break;
		}
	}
	public function getView(){
		return $this->view->defaultView();
	}
}